
package com.mancj.slideup;

import ohos.agp.components.Component;
import ohos.multimodalinput.event.TouchEvent;

/**
 * Touch consumer
 *
 * @author pa.gulko zTrap (12.07.2017)
 */
class TouchConsumer {
    /**
     * The constant M builder
     */
    SlideUpBuilder mBuilder;
    /**
     * The constant M animation processor
     */
    AnimationProcessor mAnimationProcessor;

    /**
     * The constant M can slide
     */
    boolean mCanSlide = true;
    /**
     * The constant M notifier
     */
    LoggerNotifier mNotifier;

    /**
     * The constant M view height
     */
    float mViewHeight;
    /**
     * The constant M view width
     */
    float mViewWidth;

    /**
     * The constant M start position y
     */
    float mStartPositionY;
    /**
     * The constant M start position x
     */
    float mStartPositionX;
    /**
     * The constant M prev position y
     */
    volatile float mPrevPositionY;
    /**
     * The constant M prev position x
     */
    volatile float mPrevPositionX;
    /**
     * The constant M view start position y
     */
    float mViewStartPositionY;
    /**
     * The constant M view start position x
     */
    float mViewStartPositionX;

    /**
     * Touch consumer
     *
     * @param builder            builder
     * @param notifier           notifier
     * @param animationProcessor animation processor
     */
    TouchConsumer(SlideUpBuilder builder, LoggerNotifier notifier,
                AnimationProcessor animationProcessor) {
        mBuilder = builder;
        mAnimationProcessor = animationProcessor;
        mNotifier = notifier;
    }

    /**
     * Get end int
     *
     * @return the int
     */
    int getEnd() {
        if (mBuilder.mIsRTL) {
            return mBuilder.mSliderView.getLeft();
        } else {
            return mBuilder.mSliderView.getRight();
        }
    }

    /**
     * Get start int
     *
     * @return the int
     */
    int getStart() {
        if (mBuilder.mIsRTL) {
            return mBuilder.mSliderView.getRight();
        } else {
            return mBuilder.mSliderView.getLeft();
        }
    }

    /**
     * Get top int
     *
     * @return the int
     */
    int getTop() {
        return mBuilder.mSliderView.getTop();
    }

    /**
     * Get bottom int
     *
     * @return the int
     */
    int getBottom() {
        return mBuilder.mSliderView.getBottom();
    }

    /**
     * Touch from also slide boolean
     *
     * @param touchedView touched view
     * @param event       event
     * @return the boolean
     */
    boolean touchFromAlsoSlide(Component touchedView, TouchEvent event) {
        return touchedView == mBuilder.mAlsoScrollView;
    }
}
